package com.clps.services.impl;

import com.clps.dao.UserDao;
import com.clps.domain.User;
import com.clps.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 业务层
 * @author: Eric
 * @date: 2023/9/28
 */
@Service
public class UserServiceImpl implements UserService {
    /**
     * @Autowired 对userDao进行自动装配
     * 从容器中获取userDao的对象
     */
    @Autowired
    UserDao userDao;
//    @Autowired
//    private XmlMapper mapper;

    /**
     * 调用userDao的getById()方法，获取用户单个数据
     * 并创建list集合，将用户单个数据添加进去
     * @return 最后将list集合返回给controller层
     */
    @Override
    public List<User> insertUser() {
        User user = userDao.getById();
        List<User> list = new ArrayList<>();
        list.add(user);
        //mapper.writevalueas
//        User user = Optional.ofNullable(byId).orElseGet(()->{return new User(46, "骑士兵团冲啊", "up");});
        return list;
    }
}
